package org.protege.owl.examples.tab;

import java.util.*;

import javax.swing.JTextArea;

public class VariableRegistry
{
	private Map<String,Variable> variables;
	
	public VariableRegistry()
	{
		variables= new HashMap<String,Variable>();
	}	
	public void add(Variable var)
	{
		variables.put(var.name(),var);
	}
	public boolean check(String var)
	{
		return variables.keySet().contains(var);
		
	}
	public Variable getVariable(String varName)
	{
		return variables.get(varName);
	}
	
	public void list(JTextArea textarea)
	{
		Iterator<String> keyIt = variables.keySet().iterator();
		while (keyIt.hasNext())
		{
			textarea.setText(textarea.getText()+" "+variables.get(keyIt.next()).toString());
		}
	}
	
	public void clear()
	{
		variables.clear();
	}
}